<template>
	<custom-waterfalls-flow ref="waterfallsFlowRef" :value="data.list">
		<view class="item" v-for="(item,index) in data.list" :key="index" slot="slot{{index}}" @tap="wapperClick(index)">
			<view class="title">{{item.title}}</view>
			<view class="desc">{{item.desc}}</view>
		</view>
	</custom-waterfalls-flow>

</template>

<script>
	export default {
		data() {
			return {
				currentTab: 0,
				data: {
					list: [
						// {
						// 	image: 'https://via.placeholder.com/200x500.png/ff0000',
						// 	title: '我是标题1',
						// 	date: '2022-01-01',
						// 	desc: '描述描述描述描述描述描述描述描述1',
							
						// },
						
					],


				},
				column: 2,
				pageNum: 1,
				userId:1,
			};
		},

		components: {

		},
		onLoad: function(options) {
			var that = this;
			uni.getStorage({
			key: 'userId',
			success: function (res) {
			    that.setData({
					userId:res.data,
				})
			}
			});
			this.userId = that.userId
			console.log(this.userId)
			uni.request({
				url: this.$localUrl + '/post/get/userId=' +this.userId+'/page=' + this.pageNum,
				method: 'GET',
				header: {
					"session": "shadow-test",
					'Accept': 'application/json',
					"Content-Type": "application/json",
				},
				data: {
			
				},
				success: res => {
					console.log(res.data.data)
					if (res.statusCode == 200) {
						console.log("kongjian加载成功")
						 this.data.list = res.data.data.map(item => {
						        return {
									desc: item.content,
									title:item.title,
						            image: 'https://via.placeholder.com/200x300.png/ff0000',
									hide: item.pic == ''?1:0
						        }
						    })
					console.log(this.data.list)
			
					} else {
						console.log("广场加载失败")
						uni.showToast({
							title: res.data.errorCode,
							icon: 'error',
						})
					}
			
				},
				fail: (e) => {
			
				}
			})
			// 生命周期函数--监听页面加载
		},
		onReady: function() {
			// 生命周期函数--监听页面初次渲染完成
		},
		onShow: function() {
			// 生命周期函数--监听页面显示
			
		},
		onHide: function() {
			// 生命周期函数--监听页面隐藏
		},
		onUnload: function() {
			// 生命周期函数--监听页面卸载
		},
		onPullDownRefresh: function() {
			// 页面相关事件处理函数--监听用户下拉动作
		},
		onReachBottom() {
			//上拉加载更多
			this.open = true

			// setTimeout(()=>{
			//     uni.stopPullDownRefresh();
			//     this.open = false
			// },2000)
			console.log("haha"),
				this.reset();
		},
		onShareAppMessage: function() {
			// 用户点击右上角分享
			return {
				title: 'title',
				// 分享标题
				desc: 'desc',
				// 分享描述
				path: 'path' // 分享路径
			};
		},
		methods: {
			wapperClick(item) {
				console.log('单项点击事件', item)
				uni.navigateTo({
				    url: '/pages/partner/details/details?pageId=' + item
				});
			},
			reset() {
				uni.request({
					url: this.$localUrl + '/post/get/userId= '+'/page={page}' + this.pageNum,
					method: 'GET',
					header: {
						"session": "shadow-test",
						'Accept': 'application/json',
						"Content-Type": "application/json",
					},
					data: {
				
					},
					success: res => {
						console.log(res.data.data)
						if (res.statusCode == 200) {
							console.log("广场加载成功")
							 this.data.list.concat(
							 res.data.data.map(item => {
							        return {
										desc: item.content,
										title:item.title,
							            image: 'https://via.placeholder.com/200x500.png/ff0000',
										hide: item.pic == ''?1:0
							        }
							    }))
							
						console.log(this.data.list)
				
						} else {
							console.log("广场加载失败")
							uni.showToast({
								title: res.data.errorCode,
								icon: 'error',
							})
						}
				
					},
					fail: (e) => {
				
					}
				})
			},
		},
	};
</script>

<style>
	.picture {
		border-radius: 100rpx;
		width: 150rpx;
		height: 150rpx;
		margin-top: 40rpx;
	}

	.top_place {
		text-align: center;
	}

	.content {
		margin-top: 10rpx;
		height: 900rpx;
		background-color: white;
	}
</style>
